#encoding:utf-8
=begin
class Project
	def initialize(basic_hash, project, user)
		@basic_hash = basic_hash
		@driver = basic_hash['driver']
		@base_url = basic_hash['base_url']

		@project = project

		@user = user
	end

	#项目重命名
	def rename
		show_edit
		@driver.find_element(:id, 'project_name').clear
		@driver.find_element(:id, 'project_name').send_key("re_"+@project['project_name'])
		@driver.find_element(:id, 'button').click
	end

	#项目类型设置
	def type
		show_edit
		@driver.find_element(:xpath, %Q{//a[@data-method='put']}).click
		@driver.switch_to().alert().accept()
	end

	#项目描述设置
	def desc
		show_edit
		@driver.find_element(:name, 'project[description]').send_key(@project['spec'])
		@driver.find_element(:name, 'project[home_page_url]').send_key(@project['home_page'])
		@driver.find_element(:id, 'button2').click
	end

	#删除项目
	def delete(project = @project['project_name'])
		show_edit(project)

		@driver.find_element(:xpath, %Q{//a[@data-method='delete']}).click

		@driver.switch_to().alert().dismiss()
		# @accept_next_alert = false
		# close_alert_and_get_its_text()


		@driver.find_element(:xpath, %Q{//a[@data-method='delete']}).click
		# close_alert_and_get_its_text()
		@driver.switch_to().alert().accept()
	end

	#删除该用户的所有项目
	def delete_user_all_project
		@driver.get(@base_url)
		all_projects = @driver.find_elements(:css, "#all_projects a strong")
		all_projects.each do |project|
			project_name = project.text
			delete(project_name) if project_name
		end
	end

	#创建项目
	def create
		@driver.get(@base_url + "/projects/new")
	    @driver.find_element(:id, "project_name").clear
	    @driver.find_element(:id, "project_name").send_keys @project['project_name']
	    @driver.find_element(:name, "commit").click
	end

	#跳到项目设置页面
	def show_edit(project = @project['project_name'], user = @user['username'])
		@driver.navigate.to @base_url+user+'/'+project+'/'+'edit'
		# @driver.navigate.to @base_url

	end
end
=end